package com.handong.handserialprogram.model.entities;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by userKey on 2017/8/7.
 */

public class PersonEntity implements Parcelable {

    private String name;
    private String id;

    public boolean isSelected() {
        return isSelected;
    }

    public void setSelected(boolean selected) {
        isSelected = selected;
    }

    private boolean isSelected=false;
    private transient boolean isChecked = false;

    public PersonEntity(String mName,String mId)
    {
        name=mName;
        id=mId;
    }

    protected PersonEntity(Parcel in) {
        name = in.readString();
        id = in.readString();
    }

    public static final Creator<PersonEntity> CREATOR = new Creator<PersonEntity>() {
        @Override
        public PersonEntity createFromParcel(Parcel in) {
            return new PersonEntity(in);
        }

        @Override
        public PersonEntity[] newArray(int size) {
            return new PersonEntity[size];
        }
    };

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public boolean isChecked() {
        return isChecked;
    }

    public void setChecked(boolean checked) {
        isChecked = checked;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof PersonEntity) {
            PersonEntity entity = (PersonEntity) obj;
            return this.id.equals(entity.getId());
        }
        return false;
    }

    @Override
    public String toString() {
        return "name:" + name + ", id:" + id;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(id);
        dest.writeString(name);
    }
}
